package com.foo.ajax;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow.CloseButtonCallback;
import org.apache.wicket.markup.html.WebPage;

public class Page1 extends WebPage {
	private ModalWindow modal;

	public Page1() {
		AjaxLink<Void> login = new AjaxLink<Void>("login") {

			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				modal.show(target);
			}
		};
		add(login);
		modal = new ModalWindow("modal");
		LoginPanel p = new LoginPanel(modal.getContentId()) {

			@Override
			protected void onLoggedIn(AjaxRequestTarget target) {
				modal.close(target);
			}
			
		};
		modal.setContent(p);
		modal.setTitle("Login");
		modal.setInitialWidth(300);
		modal.setInitialHeight(200);
		modal.setCloseButtonCallback(new CloseButtonCallback() {
			
			public boolean onCloseButtonClicked(AjaxRequestTarget target) {
				return false;
			}
		});
		add(modal);
	}
}